package com.openastexviewer;

import android.os.Bundle;
import android.app.Activity;
import android.view.MenuItem;
import android.view.Menu;
import android.opengl.GLSurfaceView;

public class Main extends Activity {
	private GLSurfaceView mGLView;
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_layout);
        MoleculeRenderer moleculeRenderer = new MoleculeRenderer();
        mGLView = new GlSpace(this);
        setContentView(mGLView);
        //moleculeRenderer.moleculeViewer = this;
        //moleculeRenderer.addMoleculeRendererListener(this);
        //moleculeRenderer.renderer.setColor(0x00ff00);
        //setContentView(moleculeRenderer.moleculeViewer);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main_menu, menu);
        return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle item selection
        switch (item.getItemId()) {
            case R.id.menu_open_molecule:
                OpenDialog od = new OpenDialog( this, this.getResources().getString(R.string.menu_open_molecule) );
                od.Show();
                return true;
            case R.id.menu_run_script:
                //showHelp();
                return true;
            case R.id.menu_settings:
                //showHelp();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }
    
    @Override
    protected void onPause() {
        super.onPause();
        // The following call pauses the rendering thread.
        // If your OpenGL application is memory intensive,
        // you should consider de-allocating objects that
        // consume significant memory here.
        mGLView.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        // The following call resumes a paused rendering thread.
        // If you de-allocated graphic objects for onPause()
        // this is a good place to re-allocate them.
        mGLView.onResume();
    }
}
